package com.assignment.gui;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JButton;

import com.assignment.main.Supplier;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class ViewSupplierScreen extends JFrame {

	private JPanel contentPane;
	private JButton btnExit;
	private JButton btnEdit;
	
	Supplier supplier;
	JFrame thisFrame = this;
	final SearchScreen screen;
	private JLabel collectionLabel;
	private JLabel supplierName;
	private JLabel addressLabel;
	
	/**
	 * @wbp.parser.constructor
	 */
	public ViewSupplierScreen(Supplier supplier,SearchScreen screen){
		this(screen);
		
		this.supplier=supplier;
		
		supplierName.setText(supplier.getName());
		collectionLabel.setText(supplier.getCollection());
		addressLabel.setText(supplier.getAddress());
		
	}

	/**
	 * Create the frame.
	 * @param screen 
	 * @param supplier 
	 */
	public ViewSupplierScreen(final SearchScreen screen) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 488, 335);
		this.screen=screen;
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		setVisible(true);		
		JPanel panel = new JPanel();
		panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
		panel.setBounds(180, 11, 95, 44);
		contentPane.add(panel);
		panel.setLayout(null);
		
		supplierName = new JLabel("Supplier Name");
		supplierName.setBounds(10, 11, 76, 25);
		panel.add(supplierName);
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
		panel_1.setBounds(75, 69, 342, 146);
		contentPane.add(panel_1);
		panel_1.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Collection:");
		lblNewLabel.setBounds(54, 11, 86, 29);
		panel_1.add(lblNewLabel);
		
		JLabel lblAddress = new JLabel("Address:");
		lblAddress.setBounds(54, 51, 86, 29);
		panel_1.add(lblAddress);
		
		collectionLabel = new JLabel("EXAMPLE");
		collectionLabel.setBounds(191, 11, 130, 29);
		panel_1.add(collectionLabel);
		
		addressLabel = new JLabel("EXAMPLE");
		addressLabel.setBounds(191, 51, 130, 29);
		panel_1.add(addressLabel);
		
		
		btnExit = new JButton("Exit");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		btnExit.setBounds(115, 239, 89, 23);
		contentPane.add(btnExit);
		
		btnEdit = new JButton("Edit");
		btnEdit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//Open up edit supplier screen
				
				new EditSupplierScreen(supplier, screen);
			}
		});
		btnEdit.setBounds(273, 239, 89, 23);
		contentPane.add(btnEdit);
	}
}
